-
Notifications
You must be signed in to change notification settings - Fork 121
[Mobile Payments] Fix Tap to Pay on iPhone setup failures on second account #8633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Once the CardReaderConfigProvider is set on the Terminal, it can’t be changed. This means we need to keep the same one around for the lifetime of the app in order to change it when the user logs out and back in again. Failing to do this results in serious errors when using a second account to take IPP transactions.
|
@lmischner Here's a tentative fix for part of the ToS acceptance bug. It doesn't address what happens if you cancel the ToS flow, I'll do that next week, but it does fix the happy path. It's quite a high impact fix though, so it would be great if you have some time to do exploratory testing around it, particularly covering the bluetooth reader flows, and flows where the ToS acceptance is already done. I will also do some more of this next week. Thanks! |
You can test the changes from this Pull Request by:
|
|
@lmischner I've found the Bluetooth flavour of this issue in the production app, and added testing instructions for that. On bluetooth-connection-bug-switching-accounts.mp4N.B. These repro steps don't seem to quite be 100%, and I'm not sure why it doesn't always fail, but I've tested the fix enough to have confidence in it. Based on the fix, the same can probably be done switching between reader types too, but all are fixed by this PR. |
|
@toupper Just to note that this fix is in the production code, not just the feature flagged TTPoI bit. It also fixes the bug in production as you can see from comments above. I've moved the Up to now it's treated as a singleton by I considered just keeping it on the CardReaderService, as a let property, but it's Yosemite which needs to update it, so left it in there as its own Singleton. Let me know if you have any thoughts on the way it's done. |
|
@joshheald The code looks good to me ✅ I didn't test it as the setup would take a while, so I will rely on @lmischner's and your testing. Great job! |
|
If I connect to the bluetooth reader in one account and then log out/login to another account, should the connection be maintained? Otherwise, no questions/issues found! |
Thanks for the review @lmischner – no, the connection should not be maintained in this case. When we connect to a reader we specify the (Stripe) account we're connecting for, which is unique to the store. So whenever we change account or store, we'll need to reconnect to the reader. In my testing, that's maintained, but sorry that I didn't call it out in the testing notes. |
Part of: #8290
Description
When logging out of an account after using IPP, then logging in to a second account, The Tap to Pay on iPhone connection flow was always failing, and entering a loop.
This PR prevents the flow from always failing, but does not yet fix the loop, which can still be seen if you cancel the connection flow.
Cause of the failures: not updating the
tokenProviderThe cause of this bug is that in the attempts on the second account, we're using an old
tokenProviderin the Terminal, so the locationIDs we get are being used against the wrong Stripe account (unconfirmed, but at least with the wrong token.)We correctly call
Terminal.clearCachedCredentialswhen the store is switched and when the user logs out. That means that the Terminal calls the originaltokenProvider(which it still has a reference to) to get a new token when we next connect to a reader.We can't set a new
tokenProvider, because the app crashes with this exception from Stripe:Fix
To fix it, I've put the token provider on the ServiceLocator, so that we keep hold of it for the lifetime of the app, and then the existing code will update the token that it vends, and the provider that it uses.
Concerns
This is likely just one presentation of this bug, and the fix will affect the existing bluetooth reader flow. We need to test these flows carefully.
Testing instructions
For the original bug
Menu > Settings > Experimental featuresTap to Pay on iPhoneMenu > Payments > Collect paymentCardon the payment method screenTap to Pay on iPhoneand go through the Terms of Service Apple ID linking (if you've not done so before)Connecting a Bluetooth reader
Menu > Settings > Experimental featuresTap to Pay on iPhoneMenu > Payments > Collect paymentCardon the payment method screentrunk, you can't connect.)Screenshots
ttpoi-account-linking-fix.mp4
RELEASE-NOTES.txtif necessary.